import trademark from '@/utils/http/trademark'

/*
DELETE /admin/product/baseTrademark/remove/{id}
删除BaseTrademark

POST /admin/product/baseTrademark/save
新增BaseTrademark

PUT /admin/product/baseTrademark/update
修改BaseTrademark

GET /admin/product/baseTrademark/{page}/{limit}
分页列表
*/

export interface TrademarkData {
    id?: number,
    key?: number,
    tmName: string,
    logoUrl: string,
}

export type TrademarkListData = {
    records: TrademarkData[],
    total: number,
    size: number,
    current: number,
    searchCount: boolean,
    pages: number
}

export const GetTrademarkList = (page: number, limit: number) => {
    return trademark.get<any, TrademarkListData>(`/admin/product/baseTrademark/${page}/${limit}`);
}

export const SaveOrUpdateTrademark = (trademarkInfo: TrademarkData) => {
    if(trademarkInfo.id){
        return trademark.put<any, null>('/admin/product/baseTrademark/update', trademarkInfo);
    }else{
        return trademark.post<any, null>('/admin/product/baseTrademark/save', trademarkInfo);
    }
}

export const DeleteTrademark = (id: number) => {
    return trademark.delete<any, null>(`/admin/product/baseTrademark/remove/${id}`);
}